home *** CD-ROM | disk | FTP | other *** search
/ Internet Info 1994 March / Internet Info CD-ROM (Walnut Creek) (March 1994).iso / networking / terms / tipx / xfer / zmodem.h < prev   
Encoding:
C/C++ Source or Header  |  1991-11-02  |  6.7 KB  |  211 lines

  1. /*+-------------------------------------------------------------------------
  2.     zmodem.h -- common include filefor tiprz/tipsz
  3. --------------------------------------------------------------------------*/
  4. /*+:EDITS:*/
  5. /*:05-21-1990-16:00-wht@tridom-adapt ecu xfer protocols for tipwht */
  6.  
  7. #if defined(BSD4)
  8. #include <sys/types.h>
  9. #include <sys/stat.h>
  10. #include <sgtty.h>
  11. #define OS "BSD4.x"
  12. #if defined(LLITOUT)
  13. #include <strings.h>
  14. #endif
  15. #endif
  16.  
  17. #if defined(sun)/* 4.1 */
  18. #include <string.h>
  19. #include <sys/types.h>
  20. #include <sys/stat.h>
  21. #include <termio.h>
  22. #undef ECHO
  23. #undef NL0
  24. #undef NL1
  25. #undef TAB0
  26. #undef TAB1
  27. #undef TAB2
  28. #undef XTABS
  29. #undef CR0
  30. #undef CR1
  31. #undef CR2
  32. #undef CR3
  33. #undef FF0
  34. #undef FF1
  35. #undef BS0
  36. #undef BS1
  37. #undef TOSTOP
  38. #undef FLUSHO
  39. #undef PENDIN
  40. #undef NOFLSH
  41. #include <sys/ioctl.h>
  42. #define MODE2OK
  43. #define OS "SUNOS4.1"
  44. #endif
  45.  
  46. #if defined(BSD4)
  47. #if defined(TIOCSBRK)
  48. #define CANBREAK
  49. #endif
  50. #endif
  51.  
  52. #if defined(sun)
  53. #define CANBREAK
  54. #endif
  55.  
  56. #if !defined(READCHECK)
  57. #if defined(FIONREAD)
  58. #define READCHECK
  59. #endif
  60. #if defined(SV)
  61. #define READCHECK
  62. #endif
  63. #endif
  64.  
  65. #define ACK 6
  66. #define CAN ('X'&037)
  67. #define CPMEOF 032
  68. #define ENQ 005
  69. #define EOT 4
  70. #define ERROR (-1)
  71. #define ERRORMAX 5
  72. #define FALSE 0
  73. #define NAK 025
  74. #define OK 0
  75. #define PATHLEN 257    /* ready for 4.2 bsd ? */
  76. #define RCDO (-3)
  77. #define SOH 1
  78. #define STX 2
  79. #define TIMEOUT (-2)
  80. #define TRUE 1
  81. #define UNIXFILE 0xF000    /* The S_IFMT file mask bit for stat */
  82. #define WANTCRC 0103    /* send C not NAK to get crc not checksum */
  83.  
  84. #define WANTG 0107    /* Send G not NAK to get nonstop batch xmsn */
  85. #define WCEOT (-10)
  86. #define XOFF ('s'&037)
  87. #define XON ('q'&037)
  88.  
  89. /*
  90.  * updcrc macro derived from article Copyright (C) 1986 Stephen Satchell. 
  91.  *  NOTE: First argument must be in range 0 to 255.
  92.  *        Second argument is referenced twice.
  93.  * 
  94.  * Programmers may incorporate any or all code into their programs, 
  95.  * giving proper credit within the source. Publication of the 
  96.  * source routines is permitted so long as proper credit is given 
  97.  * to Stephen Satchell, Satchell Evaluations and Chuck Forsberg, 
  98.  * Omen Technology.
  99.  */
  100.  
  101. #define updcrc(cp, crc) ( crctab[((crc >> 8) & 255)] ^ (crc << 8) ^ (cp))
  102. #define UPDC32(b, c) (cr3tab[((int)c ^ b) & 0xff] ^ ((c >> 8) & 0x00FFFFFF))
  103.  
  104.  
  105. #define ZPAD '*'    /* 052 Padding character begins frames */
  106. #define ZDLE 030    /* Ctrl-X Zmodem escape - `ala BISYNC DLE */
  107. #define ZDLEE (ZDLE^0100)    /* Escaped ZDLE as transmitted */
  108. #define ZBIN 'A'    /* Binary frame indicator */
  109. #define ZHEX 'B'    /* HEX frame indicator */
  110. #define ZBIN32 'C'    /* Binary frame with 32 bit FCS */
  111.  
  112. /* Frame types (see array "frametypes" in zm.c) */
  113. #define ZRQINIT    0    /* Request receive init */
  114. #define ZRINIT    1    /* Receive init */
  115. #define ZSINIT 2    /* Send init sequence (optional) */
  116. #define ZACK 3        /* ACK to above */
  117. #define ZFILE 4        /* File name from sender */
  118. #define ZSKIP 5        /* To sender: skip this file */
  119. #define ZNAK 6        /* Last packet was garbled */
  120. #define ZABORT 7    /* Abort batch transfers */
  121. #define ZFIN 8        /* Finish session */
  122. #define ZRPOS 9        /* Resume data trans at this position */
  123. #define ZDATA 10    /* Data packet(s) follow */
  124. #define ZEOF 11        /* End of file */
  125. #define ZFERR 12    /* Fatal Read or Write error Detected */
  126. #define ZCRC 13        /* Request for file CRC and response */
  127. #define ZCHALLENGE 14    /* Receiver's Challenge */
  128. #define ZCOMPL 15    /* Request is complete */
  129. #define ZCAN 16        /* Other end canned session with CAN*5 */
  130. #define ZFREECNT 17    /* Request for free bytes on filesystem */
  131. #define ZCOMMAND 18    /* Command from sending program */
  132. #define ZSTDERR 19    /* Output to standard error, data follows */
  133.  
  134. /* ZDLE sequences */
  135. #define ZCRCE 'h'    /* CRC next, frame ends, header packet follows */
  136. #define ZCRCG 'i'    /* CRC next, frame continues nonstop */
  137. #define ZCRCQ 'j'    /* CRC next, frame continues, ZACK expected */
  138. #define ZCRCW 'k'    /* CRC next, ZACK expected, end of frame */
  139. #define ZRUB0 'l'    /* Translate to rubout 0177 */
  140. #define ZRUB1 'm'    /* Translate to rubout 0377 */
  141.  
  142. /* zdlread return values (internal) */
  143. /* -1 is general error, -2 is timeout */
  144. #define GOTOR 0400
  145. #define GOTCRCE (ZCRCE|GOTOR)    /* ZDLE-ZCRCE received */
  146. #define GOTCRCG (ZCRCG|GOTOR)    /* ZDLE-ZCRCG received */
  147. #define GOTCRCQ (ZCRCQ|GOTOR)    /* ZDLE-ZCRCQ received */
  148. #define GOTCRCW (ZCRCW|GOTOR)    /* ZDLE-ZCRCW received */
  149. #define GOTCAN    (GOTOR|030)    /* CAN*5 seen */
  150.  
  151. /* Byte positions within header array */
  152. #define ZF0    3    /* First flags byte */
  153. #define ZF1    2
  154. #define ZF2    1
  155. #define ZF3    0
  156. #define ZP0    0    /* Low order 8 bits of position */
  157. #define ZP1    1
  158. #define ZP2    2
  159. #define ZP3    3    /* High order 8 bits of file position */
  160.  
  161. /* Bit Masks for ZRINIT flags byte ZF0 */
  162. #define CANFDX    01    /* Rx can send and receive true FDX */
  163. #define CANOVIO    02    /* Rx can receive data during disk I/O */
  164. #define CANBRK    04    /* Rx can send a break signal */
  165. #define CANCRY    010    /* Receiver can decrypt */
  166. #define CANLZW    020    /* Receiver can uncompress */
  167. #define CANFC32    040    /* Receiver can use 32 bit Frame Check */
  168. #define ESCCTL 0100    /* Receiver expects ctl chars to be escaped */
  169. #define ESC8   0200    /* Receiver expects 8th bit to be escaped */
  170.  
  171. /* Parameters for ZSINIT frame */
  172. #define ZATTNLEN 32    /* Max length of attention string */
  173. /* Bit Masks for ZSINIT flags byte ZF0 */
  174. #define TESCCTL 0100    /* Transmitter expects ctl chars to be escaped */
  175. #define TESC8   0200    /* Transmitter expects 8th bit to be escaped */
  176.  
  177. /* Parameters for ZFILE frame */
  178. /* Conversion options one of these in ZF0 */
  179. #define ZCBIN    1    /* Binary transfer - inhibit conversion */
  180. #define ZCNL    2    /* Convert NL to local end of line convention */
  181. #define ZCRESUM    3    /* Resume interrupted file transfer */
  182. /* Management include options, one of these ored in ZF1 */
  183. #define ZMSKNOLOC    0200    /* Skip file if not present at rx */
  184. /* Management options, one of these ored in ZF1 */
  185. #define ZMMASK    037    /* Mask for the choices below */
  186. #define ZMNEWL    1    /* Transfer if source newer or longer */
  187. #define ZMCRC    2    /* Transfer if different file CRC or length */
  188. #define ZMAPND    3    /* Append contents to existing file (if any) */
  189. #define ZMCLOB    4    /* Replace existing file */
  190. #define ZMNEW    5    /* Transfer if source newer */
  191.     /* Number 5 is alive ... */
  192. #define ZMDIFF    6    /* Transfer if dates or lengths different */
  193. #define ZMPROT    7    /* Protect destination file */
  194. /* Transport options, one of these in ZF2 */
  195. #define ZTLZW    1    /* Lempel-Ziv compression */
  196. #define ZTCRYPT    2    /* Encryption */
  197. #define ZTRLE    3    /* Run Length encoding */
  198. /* Extended options for ZF3, bit encoded */
  199. #define ZXSPARS    64    /* Encoding for sparse file operations */
  200.  
  201. /* Parameters for ZCOMMAND frame ZF0 (otherwise 0) */
  202. #define ZCACK1    1    /* Acknowledge, then do command */
  203.  
  204. /* FTOFFSET is offset for frametypes array in tipzm.c */
  205. #define FTOFFSET 3
  206.  
  207. long rclhdr();
  208.  
  209. #include "zlint.h"
  210. /* vi: set tabstop=4 shiftwidth=4: */
  211.